package yxy.game.pm2.module.camptower;

import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.bean.area.AreaBean;
import yxy.game.pm2.bean.module.AreaModule;
import yxy.game.pm2.bean.module.rank.PlayerRankModule;
import yxy.game.pm2.module.tower.RankTower;
import yxy.game.pm2.module.tower.TowerModule;

import java.util.Collection;

/**
 * 阵营塔排行榜-已废弃
 *
 * @ClassName RankCampTower
 * @Author jingtao-zheng
 * @Date 2022/8/2 16:23
 * @Version 1.0
 **/
@Deprecated
public class RankCampTower extends PlayerRankModule {
    private int type;//阵营类型

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public RankCampTower(AreaBean areaBean,int type) {
        super(areaBean);
        this.type = type;
    }

    @Override
    public String rankName() {
        int index = CampTowerHandle.matchRankIndex(getType());
        return PlayerRankModule.getAllRankNames().get(index);
    }

    @Override
    protected long valuePlastic(long value) {
        return value * 100;
    }

    @Override
    protected long valueRestore(long score) {
        return score / 100;
    }

    static public void reset() {
        redis().client().getKeys().deleteByPattern("AREA:*:RANK:CAMPTOWER");

        Collection<PlayerBean> all = PlayerBean.all();

        for (PlayerBean bean : all) {
            String pCode = bean.getCode();
            AreaBean areaBean = AreaModule.area(bean);
            TowerModule towerModule = TowerModule.get(pCode);
            if (towerModule.getFloor() > 0) {
                new RankTower(areaBean).put(pCode, towerModule.getFloor());
            }
        }
    }

    static public RankCampTower getRank(String playerCode,int type) {
        AreaBean areaBean = AreaModule.area(playerCode);
        return new RankCampTower(areaBean,type);
    }
}
